
import { _decorator, Component, Node, Vec2, Vec3, RigidBody, RigidBody2D } from 'cc';
import { BaseItem2D } from './BaseItem2D';
import { CollisionObj } from './game/CollisionObj';
import { Main } from './Main';
const { ccclass, property } = _decorator;


@ccclass('Monster')
export class Monster extends BaseItem2D {
	playerPos=new Vec2()
	collisionObj=new CollisionObj(this,30,30)
	isDie=false
	//rb:RigidBody2D
    start () {
		//this.rb=this.getComponent(RigidBody2D)
    }
	loop(){
		let player=Main.I.player
		if(player){
			player.getPos(this.playerPos)
			var vec=player.pos.subtract(this.pos)
			vec.normalize()
			this.setPos(this.x+vec.x,this.y+vec.y)
			//this.rb.linearVelocity=vec
		}
	}

	die(){
		this.isDie=true
	}
	
}

